<?php get_admin_header(array(
	'jquery/validate/jquery.validate.js',
	'announcement.js',
)); ?>

<h2 class="title"><?php echo ($announcement_id) ?  'Edit' : 'Add'; ?> Announcement</h2>

<form id="announcement_form" name="announcement_form" action ="<?php echo site_url('announcement/submit')?>" enctype="multipart/form-data" class="form" method ="POST" >
	<input type="hidden" id="announcement_id" name="announcement_id" value="<?php echo $announcement_id; ?>"  />

        <div class="line" style ="font-style: italic">
            Note:<br />
            *File must not be higher than 2MB in size<br /><br />
        </div>

        <div class="unit">

            <div class="line">
                    <label for="" class="">Title:</label>
                    <div class="field" style="height:auto">
                        <input type="text" name="title" id="title" value="<?php echo $title ?>"/>
                    </div>
            </div>

            <div class="line">
                    <label for="" class="">Description:</label>
                    <div class="field" style="height:auto; width:auto;">
                        <textarea id="description" name="description"><?php echo $description;?></textarea>
                    </div>
            </div>

           <div class="line">
                <label class="unit" for="file" >File Attachment: </label>
                <div class="unit field" style ="width:auto">
                    <input  type="file" name="file_name" id ="file_name">
                    <?php if ($announcement_id > 0 && ! empty($file_name) ) { ?>
                    Attached file : <a target ="_blank" href ="<?php echo site_url('announcement/download_file/'.$announcement_id) ?>" ><?php echo substr($file_name, 0, 20) ?></a>
                    <?php } ?>
                </div>
            </div>


        </div>


        <div class ="clear"></div>

	<div class="buttons">
		<button id="save" name="save">Save</button>
		<a href="<?php echo site_url('announcement/list_records'); ?>" id="cancel" name="cancel">Cancel</a>
	</div>
</form>


<script type="text/javascript">
        announcementRules();

	$('#cancel').button({
		icons: {primary: 'ui-icon-arrowreturn-1-w'}
	});	
	
	$('#save').button({
		icons: {primary: 'ui-icon-disk'}
	}).click(function(e) {
		$(this).removeClass('ui-state-focus');
		$('#announcement_form').submit();
		e.preventDefault();
	});	

</script>

<?php get_admin_footer(); ?>
